package com.syxp.pda.service.detail.impl;

import java.util.ArrayList;
import java.util.List;

import com.syxp.pda.core.bean.FieldBean;
import com.syxp.pda.core.command.QueryFilter;
import com.syxp.pda.core.util.Operation;
import com.syxp.pda.dao.detail.CheckPlanDetailDao;
import com.syxp.pda.dao.standard.DeviceCheckStandardDao;
import com.syxp.pda.entity.detail.CheckPlanDetail;
import com.syxp.pda.service.detail.ExceptionService;

public class ExceptionServiceImpl implements ExceptionService {

	private CheckPlanDetailDao checkPlanDetailDao;

	private DeviceCheckStandardDao deviceCheckStandardDao;

	public DeviceCheckStandardDao getDeviceCheckStandardDao() {
		return deviceCheckStandardDao;
	}

	public void setDeviceCheckStandardDao(
			DeviceCheckStandardDao deviceCheckStandardDao) {
		this.deviceCheckStandardDao = deviceCheckStandardDao;
	}

	public CheckPlanDetailDao getCheckPlanDetailDao() {
		return checkPlanDetailDao;
	}

	public void setCheckPlanDetailDao(CheckPlanDetailDao checkPlanDetailDao) {
		this.checkPlanDetailDao = checkPlanDetailDao;
	}

	@Override
	public List<CheckPlanDetail> selectException(QueryFilter filter) {
		filter.addFilter(new FieldBean("bugLevel", 0, Operation.GT));
		List<CheckPlanDetail> all = checkPlanDetailDao
				.getAll(filter, "dutyAll");
		return all;
	}

	@Override
	public List<Object[]> exceptionCount(QueryFilter filter) {
		List<FieldBean> projections = new ArrayList<FieldBean>() ;
		projections.add(new FieldBean("zoneName" ,null ,null)) ;
		projections.add(new FieldBean("devName" ,null, null)) ;
		projections.add(new FieldBean("pda_CHKDatetime" ,null ,Operation.MIN)) ;
		projections.add(new FieldBean("pda_CHKDatetime" ,null ,Operation.MAX)) ;
		projections.add(new FieldBean("autoID" ,null ,Operation.COUNT)) ;
		projections.add(new FieldBean("zoneName" ,null ,Operation.GROUP)) ;
		projections.add(new FieldBean("devName" ,null ,Operation.GROUP)) ;
		filter.addProject(projections) ;
		return checkPlanDetailDao.getAll(filter, "dutyAll");
	}

}
